class Convertor extends Object
commonElementStart()
and
commonElementEnd()
methods. Elements requiring special care during
the conversion are converted by calling special methods like
tableRowStart()
.Modifier and Type | Field and Description |
---|---|
private HashMap<String,String> |
_biblio
Document's bibliography.
|
private Configuration |
_config
Program configuration.
|
private int |
_countIgnoreContentElements
Counter telling in how many elements with
"ignoreContent" attribute the parser is.
|
private int |
_countLeaveTextElements
Counter telling in how many elements with
"leaveText" attribute the parser is.
|
private boolean |
_firstCell
If table cell is reached is it first table cell?
|
private boolean |
_firstRow
If table row is reached is it first table row?
|
private FileWriter |
_fw
Output file.
|
private File |
_outputFile
Output file.
|
private boolean |
_printBorder
Shall border be printed in current table.
|
private BufferedWriter |
_writer
Output file.
|
Constructor and Description |
---|
Convertor(File outputFile,
String configFilePath)
Opens the output file.
|
Modifier and Type | Method and Description |
---|---|
void |
anchorEnd(ElementEnd element,
ElementStart es)
Called when A end element is reached.
|
void |
anchorStart(ElementStart e)
Called when A start element is reached.
|
void |
bodyEnd(ElementEnd element,
ElementStart es)
Called when end element is reached.
|
void |
bodyStart(ElementStart es)
Called when BODY start element is reached.
|
void |
characters(String str)
Called when text content is reached in the input HTML document.
|
void |
comment(String comment)
Called when comment is reached in the input HTML document.
|
void |
commonElementEnd(ElementEnd element,
ElementStart es)
Called when HTML end element is reached and special method for
the element doesn't exist.
|
void |
commonElementStart(ElementStart element)
Called when HTML start element is reached and special method for
the element doesn't exist.
|
private String |
convertCharEntitites(String str)
Converts HTML character entities to LaTeX commands.
|
private String |
convertLaTeXSpecialChars(String str)
Converts LaTeX special characters (ie. '{') to LaTeX commands.
|
void |
cssStyleEnd(ElementStart e)
Prints CSS style converted to LaTeX command.
|
void |
cssStyleStart(ElementStart e)
Prints CSS style converted to LaTeX command.
|
void |
destroy()
Closes the output file.
|
private CSSStyle[] |
findStyles(ElementStart e)
Finds styles for the specified element.
|
void |
fontEnd(ElementEnd e,
ElementStart es)
Called when FONT end element is reached.
|
void |
fontStart(ElementStart es)
Called when FONT start element is reached.
|
void |
imgStart(ElementStart es)
Called when IMG start element is reached.
|
void |
metaStart(ElementStart es)
Called when META start element is reached.
|
private void |
processAttributes(ElementStart element)
Processes HTML elements' attributes.
|
void |
tableCellEnd(ElementEnd element,
ElementStart e)
Called when TD end element is reached.
|
void |
tableCellStart(ElementStart e)
Called when TD start element is reached.
|
void |
tableEnd(ElementEnd e,
ElementStart es)
Called when TABLE end element is reached.
|
void |
tableRowEnd(ElementEnd e,
ElementStart es)
Called when TR end element is reached.
|
void |
tableRowStart(ElementStart e)
Called when TR start element is reached.
|
void |
tableStart(ElementStart e)
Called when TABLE start element is reached.
|
private Configuration _config
private File _outputFile
private FileWriter _fw
private BufferedWriter _writer
private int _countLeaveTextElements
private int _countIgnoreContentElements
private boolean _firstCell
private boolean _firstRow
private boolean _printBorder
Convertor(File outputFile, String configFilePath) throws FatalErrorException
outputFile
- output LaTeX fileconfigFilePath
- the absolute path of the XML config fileFatalErrorException
- when output file can't be openedpublic void destroy()
public void commonElementStart(ElementStart element) throws IOException, NoItemException
element
- HTML start tagIOException
- output error occursNoItemException
- tag not found in the configurationpublic void commonElementEnd(ElementEnd element, ElementStart es) throws IOException, NoItemException
element
- corresponding end tages
- start tagIOException
- output error occursNoItemException
- tag not found in the configurationpublic void characters(String str) throws IOException
str
- text content reachedIOException
- when output error occurspublic void comment(String comment) throws IOException
comment
- comment (without <!-- and -->)IOException
- when output error occursprivate String convertLaTeXSpecialChars(String str)
str
- input stringprivate String convertCharEntitites(String str)
str
- input stringprivate void processAttributes(ElementStart element) throws IOException
element
- HTML start tagIOException
- when output error occurspublic void cssStyleStart(ElementStart e) throws IOException
e
- HTML start elementIOException
- when output error occurspublic void cssStyleEnd(ElementStart e) throws IOException
e
- corresponding HTML start elementIOException
- when output error occursprivate CSSStyle[] findStyles(ElementStart e)
e
- HTML elementpublic void anchorStart(ElementStart e) throws IOException, NoItemException
e
- start tagIOException
- output error occursNoItemException
- tag not found in the configurationpublic void anchorEnd(ElementEnd element, ElementStart es) throws IOException, NoItemException
element
- corresponding end tages
- start tagIOException
- output error occursNoItemException
- tag not found in the configurationpublic void tableRowStart(ElementStart e) throws IOException, NoItemException
e
- start tagIOException
- output error occursNoItemException
- tag not found in the configurationpublic void tableRowEnd(ElementEnd e, ElementStart es) throws IOException
e
- corresponding end tages
- start tagIOException
- output error occurspublic void tableCellStart(ElementStart e) throws IOException, NoItemException
e
- start tagIOException
- output error occursNoItemException
- tag not found in the configurationpublic void tableCellEnd(ElementEnd element, ElementStart e) throws IOException, NoItemException
element
- corresponding end tage
- start tagIOException
- output error occursNoItemException
- tag not found in the configurationpublic void tableStart(ElementStart e) throws IOException, NoItemException
e
- start tagIOException
- output error occursNoItemException
- tag not found in the configurationpublic void tableEnd(ElementEnd e, ElementStart es) throws IOException, NoItemException
e
- corresponding end tages
- start tagIOException
- output error occursNoItemException
- tag not found in the configurationpublic void bodyStart(ElementStart es) throws IOException, NoItemException
es
- start tagIOException
- output error occursNoItemException
- tag not found in the configurationpublic void imgStart(ElementStart es) throws IOException, NoItemException
es
- start tagIOException
- output error occursNoItemException
- tag not found in the configurationpublic void metaStart(ElementStart es) throws IOException, NoItemException
es
- start tagIOException
- output error occursNoItemException
- tag not found in the configurationpublic void fontStart(ElementStart es) throws IOException, NoItemException
es
- start tagIOException
- output error occursNoItemException
- tag not found in the configurationpublic void fontEnd(ElementEnd e, ElementStart es) throws IOException, NoItemException
e
- corresponding end tages
- start tagIOException
- output error occursNoItemException
- tag not found in the configurationpublic void bodyEnd(ElementEnd element, ElementStart es) throws IOException, NoItemException
element
- corresponding end tages
- start tagIOException
- output error occursNoItemException
- tag not found in the configuration